/**
 * @author Arian Stolwijk
 */

var Awf = Awf ? Awf : {};

Awf.imageHover = new Class({
	version: 1.0,
	
	initialize: function(elmt,additionString){
		var additionString = $type(additionString) == 'string' ? additionString : '_hover';
		elmt = $(elmt);
		if(elmt.get('tag') == 'img'){
			elmt.addEvents({
				'mouseover': function(){
					this.set('src',this.get('src').replace(/\.(jpeg|jpg|png|gif)$/i,function(ext){
						return additionString + ext;
					}));
				},
				'mouseout': function(){
					this.set('src',this.get('src').replace(additionString,''));
				}
			});
		}
	}
	
});

Element.implement({	
	imageHover: function(additionString){
		new Awf.imageHover(this,additionString);
		return this;
	}	
});
